package com.jeethink.erp.stockDetail.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jeethink.common.annotation.Log;
import com.jeethink.common.core.controller.BaseController;
import com.jeethink.common.core.domain.AjaxResult;
import com.jeethink.common.enums.BusinessType;
import com.jeethink.erp.stockDetail.domain.TbEnterStockDetail;
import com.jeethink.erp.stockDetail.service.ITbEnterStockDetailService;
import com.jeethink.common.utils.poi.ExcelUtil;
import com.jeethink.common.core.page.TableDataInfo;

/**
 * 入库单详细信息Controller
 * 
 * @author ypr
 * @date 2021-06-01
 */
@RestController
@RequestMapping("/erp/stockDetail")
public class TbEnterStockDetailController extends BaseController
{
    @Autowired
    private ITbEnterStockDetailService tbEnterStockDetailService;

    /**
     * 查询入库单详细信息列表
     */
    @PreAuthorize("@ss.hasPermi('erp:stockDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbEnterStockDetail tbEnterStockDetail)
    {
        startPage();
        List<TbEnterStockDetail> list = tbEnterStockDetailService.selectTbEnterStockDetailList(tbEnterStockDetail);
        return getDataTable(list);
    }

    /**
     * 导出入库单详细信息列表
     */
    @PreAuthorize("@ss.hasPermi('erp:stockDetail:export')")
    @Log(title = "入库单详细信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbEnterStockDetail tbEnterStockDetail)
    {
        List<TbEnterStockDetail> list = tbEnterStockDetailService.selectTbEnterStockDetailList(tbEnterStockDetail);
        ExcelUtil<TbEnterStockDetail> util = new ExcelUtil<TbEnterStockDetail>(TbEnterStockDetail.class);
        return util.exportExcel(list, "stockDetail");
    }

    /**
     * 获取入库单详细信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('erp:stockDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbEnterStockDetailService.selectTbEnterStockDetailById(id));
    }

    /**
     * 新增入库单详细信息
     */
    @PreAuthorize("@ss.hasPermi('erp:stockDetail:add')")
    @Log(title = "入库单详细信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbEnterStockDetail tbEnterStockDetail)
    {
        return toAjax(tbEnterStockDetailService.insertTbEnterStockDetail(tbEnterStockDetail));
    }

    /**
     * 修改入库单详细信息
     */
    @PreAuthorize("@ss.hasPermi('erp:stockDetail:edit')")
    @Log(title = "入库单详细信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbEnterStockDetail tbEnterStockDetail)
    {
        return toAjax(tbEnterStockDetailService.updateTbEnterStockDetail(tbEnterStockDetail));
    }

    /**
     * 删除入库单详细信息
     */
    @PreAuthorize("@ss.hasPermi('erp:stockDetail:remove')")
    @Log(title = "入库单详细信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbEnterStockDetailService.deleteTbEnterStockDetailByIds(ids));
    }
}
